package lifeOfAFish.scenegraph.geom;

import javax.media.opengl.GL;

import lifeOfAFish.scenegraph.sgGeometry;
import lifeOfAFish.scenegraph.sgGlobals;

import com.loader.WavefrontObject;

public class sgGeomModel extends sgGeometry {
	
	//
	// Fields
	// 
	private String m_filename = null;
	private WavefrontObject m_model = null;
	

	//
	// Constructors
	//
	public sgGeomModel () 
	{
	};

	//
	// Methods
	//


	//
	// Accessor methods
	//

	//
	// Other methods
	//

	public void setOBJFileName(String name){
		m_filename = name;
	}

	public void load()
	{
		com.loader.glWrapper.gl = sgGlobals.gl;
		m_model = new WavefrontObject(m_filename);
	}

	/**
	 * Render the model, optional binding texture if necessary
	 */
	protected void draw()
	{
		GL gl = sgGlobals.gl;
		gl.glEnable(GL.GL_COLOR_MATERIAL);
		gl.glEnable(GL.GL_TEXTURE_2D);
		m_model.render();
		gl.glDisable(GL.GL_COLOR_MATERIAL);
		gl.glDisable(GL.GL_TEXTURE_2D);
	};
	
	/**
	 * Return (local) bounding box
	 */
	public float[] getBoundingBox(){
		// stub for now
		float[] bb = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
		return bb;
	}
	
}
